<template>
<div class="real-name-authentication-page">
    <!-- 导航栏 -->
    <van-nav-bar title="完善信息" left-arrow @click-left="goBack" />
    <van-form @submit="onSubmit">
        <van-cell-group inset>
            <van-field
                v-model="form.name"
                name="姓名"
                label="姓名"
                required
                placeholder="请输入姓名"
                :rules="[{ required: true, message: '请填写姓名' }]"
            />
            <van-field
                v-model="form.phone"
                type="text"
                required
                name="手机号"
                label="手机号"
                placeholder="请输入手机号"
                :rules="[{ required: true, message: '请填写手机号' }]"               
            />
            <van-field
                v-model="form.ppname"
                type="text"
                name="销售品牌"
                label="销售品牌"
                placeholder="请输入销售品牌"
            />
        </van-cell-group>
        <div style="margin: 16px;">
            <van-button round block type="primary" native-type="submit">
            提交
            </van-button>
        </div>
        </van-form>
    </div>
</template>

<script>
import { updateHyinfo } from '@/api/api';
import { getHyinfo } from '../../api/api';
export default {
    data() {
        return {
            realName: '',
            phoneNumber: '',
            verificationCode: '',
            form:{

            },
            rules: {
                
            },
            hyid:undefined

        };
    },
    created(){
        this.hyid = this.$route.query.hyid
        this.getHyinfo()
    },
    methods: {
        onSubmit(){
            console.log(this.form)
            this.form.hyid = this.hyid
            updateHyinfo(this.form).then(res=>{
                if(res.code == 200){
                    this.$toast('提交成功')
                    this.$router.back()
                }else{
                    this.$toast(res.msg)
                }
            })
        },

        getHyinfo(){
            let param = {
                hyid:this.hyid   
            }
            getHyinfo(param).then(res=>{
                if(res.code == 200){
                    this.form = res.data
                }
            })
        },
        goBack() {
        // 处理返回上一页逻辑，例如使用路由返回
        this.$router.back();
        },
        getVerificationCode() {
        // 处理获取验证码逻辑，例如调用后端接口发送验证码
        console.log('点击获取验证码，手机号为：', this.phoneNumber);
        },
        submitAuthentication() {
        // 处理提交实名认证逻辑，例如将数据发送到后端进行验证保存
        console.log('提交实名认证，姓名：', this.realName, '，手机号：', this.phoneNumber, '，验证码：', this.verificationCode);
        }
    }
};
</script>
    
<style scoped>
.real-name-authentication-page {
    background-color: #fff;
}
.prompt-section {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}
.required {
    color: red;
    margin-right: 5px;
    }
</style>